#include "HeightWidth.h"

inline int HeightWidth::true_mod(int a, int b) const {
	int result = a % b;
	while (result < 0) {
		result += b;
	}
	while (result >= b) {
		result -= b;
	}
	return result;
}

HeightWidth HeightWidth::operator +(const HeightWidth& b) const {
	HeightWidth result(height + b.getHeight(), width + b.getWidth());
	return result;
}

HeightWidth HeightWidth::operator %(const HeightWidth& b) const {
	HeightWidth result(true_mod(height, b.getHeight()), true_mod(width, b.getWidth()));
	return result;
}

void HeightWidth::setHeight(int h) {
    height = h;
}

void HeightWidth::setWidth(int w) {
    width = w;
}

int HeightWidth::getHeight() const {
    return height;
}

int HeightWidth::getWidth() const {
    return width;
}

bool HeightWidth::operator < (const HeightWidth& b) const {
    if ((width < b.getWidth()) and (height < b.getHeight())) return true;
    return false;
}

HeightWidth::HeightWidth() {
}

HeightWidth::HeightWidth(int h, int w) {
    height = h;
    width = w;
}

HeightWidth::~HeightWidth() {
}
